package com.tricode.ile.training.task.one.calculatesumofelementsinarray;

import java.util.Scanner;

import com.tricode.ile.training.task.one.helpers.PrintArray;

public class MainSumCalculator {

	public static void main(String[] args) {

		CalculateSumFromArray calculateSumFromArray = new CalculateSumFromArray();

		Scanner scanner = new Scanner(System.in);
		int[] array = new int[5000];
		int i = 0;
		System.out.println("Enter the elements(enter char to gain the result):");
		while (scanner.hasNextInt()) {
			array[i] = scanner.nextInt();
			i++;
		}
		scanner.close();
		int[] newArray = new int[i];
		System.arraycopy(array, 0, newArray, 0, i);
		
		PrintArray printArray = new PrintArray();
		System.out.println("This is the array you entered:");
		printArray.printArrayOfIntegers(newArray);
		
		int sum = calculateSumFromArray.getSum(newArray);
		System.out.println("The sum of the elements you entered is: "+sum);
	}

}
